package com.atguigu.juc.study.chapter10.reference;

import java.util.concurrent.TimeUnit;

/**
 * @author : leimingchao
 * @date Date : 2022年06月19日 17:58
 */
public class StrongReferenceDemo {

    public static void main(String[] args) {

        MyObject myObject = new MyObject();
        System.out.println("gc before:" + myObject);

        myObject = null;
        //人工开启GC,一般不用

        try {
            TimeUnit.MILLISECONDS.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.gc();
        System.out.println("gc after:" + myObject);


    }
}
